﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Text.RegularExpressions;

/// <summary>
/// Summary description for Utils
/// </summary>
public class Utils
{
    /*==============================================*/
    //Author: NhanDT 21/12/2010.
    //Email: nhandt@lichsu.vn
    //Website: http://lichsu.vn
    /*==============================================*/
    /// <summary>
    /// Hàm chuyển đổi chuỗi có dấu thành không dấu
    /// </summary>
    /// <param name="text"></param>
    /// <returns></returns>
    public static string ConvertToUnSign(string text)
    {
        text.ToLower();
        for (int i = 33; i < 48; i++)
        {
            text = text.Replace(((char)i).ToString(), "");
        }

        for (int i = 58; i < 65; i++)
        {
            text = text.Replace(((char)i).ToString(), "");
        }

        for (int i = 91; i < 97; i++)
        {
            text = text.Replace(((char)i).ToString(), "");
        }

        for (int i = 123; i < 127; i++)
        {
            text = text.Replace(((char)i).ToString(), "");
        }

        text = text.Replace(" ", "-");

        Regex regex = new Regex(@"\p{IsCombiningDiacriticalMarks}+");

        string strFormD = text.Normalize(System.Text.NormalizationForm.FormD);
        return regex.Replace(strFormD, String.Empty).Replace('\u0111', 'd').Replace('\u0110', 'D');
    }

    public Utils()
    {
        //
        // TODO: Add constructor logic here
        //
    }
}
